<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Facelet Title</title>
        <h:outputScript library="javascript" name="moeda.js" />
        <h:outputStylesheet library="css" name="estilo.css" />
        <h:outputScript name="primef.js" library="javascript" />  
    </h:head>
    <h:body>
        <ui:composition template="menu_admin.xhtml" >
            <ui:define name="divmeio">

                <br />
                <br />
                <center><h:outputText value="CadastrarProduto" style="color: blue; font-size: 35px "/></center>
                <br />
                <hr />

                <p:tabView orientation="left" activeIndex="#{adminSessionMB.activeIndex}"> 
                    <p:ajax event="tabChange" listener="#{adminSessionMB.onTabChange}" />
                    <p:tab title="Informações básica" >  
                        <h:form id="addProdutoAdmin1">
                            <p:panelGrid  styleClass="semBorda" id="GaddProdutoAdmin1">
                                <p:row>
                                    <p:column style="text-align: right">
                                        <h:outputText value="Nome" />
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText value="#{adminSessionMB.produto.nome}" required="true" id='ITNomeProduto'
                                                     requiredMessage="digite um nome para o produto"/>
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITNomeProduto" />  
                                    </p:column>
                                </p:row>

                                <p:row>
                                    <p:column style="text-align: right">
                                        <h:outputText value="Peso (pacote)" />
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText value="#{adminSessionMB.produto.peso}" required="true" style="width:60px;" id="ITPeso" 
                                                     requiredMessage="digite um peso, pode ser numeros com casas decimais">
                                            <f:validateDoubleRange minimum="0.00"/> 

                                        </p:inputText>
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITPeso" />  
                                    </p:column>
                                </p:row>

                                <p:row>
                                    <p:column style="text-align: right">
                                        <h:outputText value="Altura (pacote)" />
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText id="ITAltura" value="#{adminSessionMB.produto.altura}" style="width:60px;" required="true"
                                                     requiredMessage="digite uma altura, somente numeros inteiros"
                                                     validatorMessage="digite uma altura, somente numeros inteiros">
                                            <f:validateDoubleRange minimum="1"/> 
                                        </p:inputText>
                                        <h:outputText value="cm" />
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITAltura" />  
                                    </p:column>
                                </p:row>



                                <p:row>
                                    <p:column style="text-align: right">
                                        <h:outputText value="Comprimento (pacote)" />
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText id="ITComprimento" value="#{adminSessionMB.produto.comprimento}" style="width:60px;" required="true"
                                                     requiredMessage="digite um comprimento, somente numeros inteiros">
                                            <f:validateDoubleRange minimum="1"/> 
                                        </p:inputText>
                                        <h:outputText value="cm" />
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITComprimento" />  
                                    </p:column>
                                </p:row>


                                <p:row>
                                    <p:column style="text-align: right">
                                        <h:outputText value="Largura (pacote)" />
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText id="ITLargura" value="#{adminSessionMB.produto.largura}" style="width:60px;" required="true"
                                                     requiredMessage="digite uma largura, somente numeros inteiros">
                                            <f:validateDoubleRange minimum="1" /> 
                                        </p:inputText>
                                        <h:outputText value="cm" />
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITLargura"  />  
                                    </p:column>
                                </p:row>

                            </p:panelGrid>
                            <hr />
                            <p:commandButton value="Proximo" icon="ui-icon-circle-arrow-e" action="#{adminSessionMB.gravaProdutoAvancar()}" validateClient="true" ajax="false"/>
                        </h:form>
                    </p:tab>  



                    <p:tab title="Tipo de produto"> 
                        <h:form id="addProdutoAdmin2">
                            <p:panelGrid id="GaddProdutoAdmin2">
                                <p:row>
                                    <p:column style="text-align: right">
                                        <h:outputText value="Estoque mínimo" />
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText value="#{adminSessionMB.estoqueMinimoAux}" id="ITEstoqueMinimo" style="width:60px;" required="true"
                                                     requiredMessage="digite uma altura, somente numeros inteiros">
                                            <f:validateDoubleRange minimum="1"/>  
                                        </p:inputText>
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITEstoqueMinimo"/> 
                                    </p:column>
                                </p:row>
                                <p:row>
                                    <p:column style="text-align: right">
                                        Estoque inicial
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        <p:inputText value="#{adminSessionMB.estoqueInicialAux}" id="ITEstoqueIncial" style="width:60px;" required="true">
                                            <f:validateDoubleRange minimum="1"/>  
                                        </p:inputText>
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITEstoqueIncial" />  
                                    </p:column>
                                </p:row>
                                <p:row>
                                    <p:column style="text-align: right">
                                        Cor
                                    </p:column>
                                    <p:column>
                                        <p:colorPicker value="#{adminSessionMB.corAux}" />
                                    </p:column>
                                </p:row>

                                <p:row>
                                    <p:column style="text-align: right">
                                        Tamanho
                                    </p:column>
                                    <p:column>
                                        <p:inputText value="#{adminSessionMB.tamanhoAux}" id="ITTamanho" style="width:60px;"/>
                                        <p:tooltip for="ITTamanho" value="ex: M , PP, usado mais para roupas" showEffect="clip" hideEffect="explode" />
                                    </p:column>
                                    <p:column>
                                        <p:message for="ITTamanho" />  
                                    </p:column>
                                </p:row>
                            </p:panelGrid>
                            <br/>
                            <p:commandButton icon="ui-icon-circle-plus" value="Criar novo tipo" update="tablecorTB" action="#{adminSessionMB.addTipoNaLista()}"/>
                            <br/>
                            <br/>
                            <p:dataTable  value="#{adminSessionMB.listaTipoProduto}" var="item" id="tablecorTB">
                                <f:facet name="header" >  
                                    Tipos já cadastrados 
                                </f:facet>  
                                <p:column headerText="Estoque mínimo" >
                                    <h:outputText value="#{item.estoqueMinimo}"/>
                                </p:column>

                                <p:column headerText="Estoque inicial" >
                                    <h:outputText value="#{item.estoqueInicial}"/>
                                </p:column>
                                <p:column headerText="Cor" >
                                    <p:panel style="background-color: #{item.cor}" />
                                </p:column>
                                <p:column headerText="Tamanho" >
                                    <h:outputText value="#{item.tamanho}"/>
                                </p:column>
                                <p:column style="width: 6%">
                                    <p:commandButton  icon="ui-icon-trash" update="tablecorTB" actionListener="#{adminSessionMB.removeItemTipo(item)}"/>
                                </p:column>
                            </p:dataTable>
                            <br />
                            <hr />

                            <p:commandButton ajax="false" value="Proximo" icon="ui-icon-circle-arrow-e" action="#{adminSessionMB.gravaProdutoAvancar()}" validateClient="true" />

                        </h:form>
                    </p:tab>  

                    <p:tab title="Valores/Promoção/Oferta">  
                        <h:form id="addProdutoAdmin3">
                            <p:panelGrid styleClass="semBorda">
                                <p:row>
                                    <p:column>
                                        Preço de compra
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        R$
                                        <p:inputText value="#{adminSessionMB.produto.precoDeCompra}" id="valorCompraIT" onkeypress="return(MascaraMoeda(this, '', '.', event));" style="width: 60px" required="true">
                                            <f:validateDoubleRange minimum="0.00"/> 
                                            <f:ajax render="valorFinalOT"  event="blur"/>
                                        </p:inputText>
                                        <p:tooltip for="valorCompraIT" value="O custo pelo qual você pagou pelo produto" showEffect="clip" hideEffect="explode" />
                                    </p:column>
                                </p:row>

                                <p:row>
                                    <p:column>
                                        Margem de lucro
                                        <h:outputText value="*" style="color: red"/>
                                    </p:column>
                                    <p:column>
                                        R$
                                        <p:inputText  value="#{adminSessionMB.produto.margemLucro}" required="true" id="margemLucroIT" onkeypress="return(MascaraMoeda(this, '', '.', event));" style="width: 60px">
                                            <f:validateDoubleRange minimum="0.00"/>
                                            <f:ajax render="valorFinalOT"  event="blur"/>
                                        </p:inputText>    
                                        <p:tooltip for="margemLucroIT" value="Lucro em que você quer ganhar no produto" showEffect="clip" hideEffect="explode" />
                                    </p:column>
                                </p:row>
                                <p:row>
                                    <p:column>
                                        Valor final do produto
                                    </p:column>
                                    <p:column>
                                        R$
                                        <h:outputText value="#{adminSessionMB.valorFinalProduto}" id="valorFinalOT" />
                                    </p:column>
                                </p:row>
                            </p:panelGrid>
                            <p:panelGrid columns="2" styleClass="semBorda">
                                <p:panelGrid columns="2">
                                    Em Oferta
                                    <p:selectOneMenu value="#{adminSessionMB.rendCadastroOferta}">
                                        <f:selectItem itemLabel="Não" itemValue="false" />
                                        <f:selectItem itemLabel="Sim" itemValue="true"/>
                                        <f:ajax render="PGdeOfertasss" />
                                    </p:selectOneMenu>
                                </p:panelGrid>

                                <h:panelGroup id="PGdeOfertasss">
                                    <h:panelGroup rendered="#{adminSessionMB.rendCadastroOferta}">
                                        <fieldset>
                                            <legend>Informações sobre a Oferta</legend>
                                            <p:panelGrid columns="2">
                                                <h:outputText value="Data inicio da oferta" />
                                                <p:calendar pattern=" dd-MM-yyyy" showButtonPanel="true" navigator="true" value="#{adminSessionMB.itemEventoOferta.inicio}" />    
                                                <h:outputText value="Data final da oferta" />
                                                <p:calendar pattern=" dd-MM-yyyy" showButtonPanel="true" navigator="true" value="#{adminSessionMB.itemEventoOferta.fim}"/> 
                                            </p:panelGrid>
                                        </fieldset>
                                    </h:panelGroup>
                                </h:panelGroup>
                                <p:panelGrid columns="2">
                                    <h:outputText value="Em Promoção" />  
                                    <p:selectOneMenu value="#{adminSessionMB.rendCadastroPromocao}">
                                        <f:selectItem itemLabel="Não" itemValue="false" />
                                        <f:selectItem itemLabel="Sim" itemValue="true"/>
                                        <f:ajax render="PGdeProomocao" />
                                    </p:selectOneMenu>
                                </p:panelGrid>
                                <h:panelGroup id="PGdeProomocao">
                                    <h:panelGroup rendered="#{adminSessionMB.rendCadastroPromocao}">
                                        <fieldset>
                                            <legend>Informações sobre promoção</legend>
                                            <p:panelGrid>
                                                <p:row>
                                                    <p:column>
                                                        Valor do desconto 
                                                    </p:column>
                                                    <p:column>
                                                        R$ 
                                                        <p:inputText id="descoPromoIT" onkeypress="return(MascaraMoeda(this, '', '.', event));"  required="true" value="#{adminSessionMB.itemEventoPromocao.desconto}" style="width: 60px">
                                                            <f:validateDoubleRange minimum="0.00"/> 
                                                        </p:inputText>
                                                    </p:column>
                                                    <p:column>
                                                        <p:message for="descoPromoIT"  showDetail="false" showSummary="false"/>  
                                                    </p:column>
                                                </p:row>
                                                <p:row>
                                                    <p:column>
                                                        Data inicio da promoção
                                                    </p:column>
                                                    <p:column>
                                                        <p:calendar pattern=" dd-MM-yyyy" showButtonPanel="true" navigator="true" value="#{adminSessionMB.itemEventoPromocao.inicio}"/>    
                                                    </p:column>
                                                </p:row>
                                                <p:row>
                                                    <p:column>
                                                        Data final da promoção
                                                    </p:column>
                                                    <p:column>
                                                        <p:calendar pattern=" dd-MM-yyyy" showButtonPanel="true" navigator="true" value="#{adminSessionMB.itemEventoPromocao.inicio}"/>   
                                                    </p:column>
                                                </p:row>
                                            </p:panelGrid>
                                        </fieldset>
                                    </h:panelGroup>
                                </h:panelGroup>
                            </p:panelGrid>
                            <p:commandButton ajax="false" value="Proximo" icon="ui-icon-circle-arrow-e" action="#{adminSessionMB.gravaProdutoAvancar()}" validateClient="true" />
                        </h:form>
                    </p:tab> 


                    <!--                    N
                                        N
                                        N
                                        n
                                        n
                                        n
                                        n
                                        n
                                        n
                                        n-->

                    <p:tab title="Godfather Part III">  

                    </p:tab>  

                </p:tabView>  


                <h:panelGroup rendered="false">
                    <!--PRIMEIRA PARTE-->




                    <br />
                    <hr />
                    <br />


                    <!--SEGUNDA PARTE-->





                    <br />
                    <hr />
                    <br />
                    <!--TERCEIRA PARTE-->

                    <p:selectOneRadio id="EstoqueAcabandoSOR" layout="custom">  
                        <f:selectItem itemLabel="Ativar" itemValue="true" />  
                        <f:selectItem itemLabel="Desativar" itemValue="false" />
                    </p:selectOneRadio>  

                    <p:selectOneRadio id="situacaoSOR" layout="custom">  
                        <f:selectItem itemLabel="Ativar" itemValue="true" />  
                        <f:selectItem itemLabel="Desativar" itemValue="false" />  
                    </p:selectOneRadio>  

                    <p:selectOneRadio id="dispPVendaSOR" layout="custom">  
                        <f:selectItem itemLabel="Ativar" itemValue="true" />  
                        <f:selectItem itemLabel="Desativar" itemValue="false" />
                    </p:selectOneRadio>  


                    <p:panelGrid columns="2"  style="text-align: right">

                        <h:outputText value="Apresentar para o cliente" />
                        <p:panelGrid columns="2" >
                            <p:panelGrid columns="3">
                                <p:graphicImage library="imagem" name="positivar.png" width="20" height="20" alt="Ativar" />
                                <p:radioButton id="opt1" for="situacaoSOR" itemIndex="0"/> 
                                <h:outputLabel for="opt1" value="      Ativar" />  
                                <p:tooltip for="opt1" value="Se marcado aparecerá para o produto para o cliente " showEffect="clip" hideEffect="explode" />
                            </p:panelGrid>

                            <p:column />
                            <p:panelGrid columns="3">
                                <p:graphicImage library="imagem" name="Error_Icon.png" width="20" height="20" alt="Desativar" />
                                <p:radioButton id="opt2" for="situacaoSOR" itemIndex="1"/>  
                                <h:outputLabel for="opt2" value="Desativar" />  
                                <p:tooltip for="opt2" value="Se marcado não aparecerá para o cliente o produto" showEffect="clip" hideEffect="explode" />  
                            </p:panelGrid>
                        </p:panelGrid>



                        <h:outputText value="Disponibilizar para venda" />
                        <p:panelGrid columns="2" >
                            <p:panelGrid columns="4">
                                <p:graphicImage library="imagem" name="positivar.png" width="20" height="20" alt="Ativar" />
                                <p:radioButton id="opt11" for="dispPVendaSOR" itemIndex="0"/>  
                                <h:outputLabel for="opt11" value="Ativar" />  
                                <p:tooltip for="opt11" value="Se marcado aparecerá o valor do produto" showEffect="clip" hideEffect="explode" />  
                            </p:panelGrid>

                            <p:column />
                            <p:panelGrid columns="4">
                                <p:graphicImage library="imagem" name="Error_Icon.png" width="20" height="20" alt="Desativar" />
                                <p:radioButton id="opt22" for="dispPVendaSOR" itemIndex="1"/> 
                                <h:outputLabel for="opt22" value="Desativar" /> 
                                <p:tooltip for="opt22" value="Se marcado no lugar do preco aparecerá um botão (me avise quando chegar) " showEffect="clip" hideEffect="explode" />  
                            </p:panelGrid>
                        </p:panelGrid>


                        <h:outputText value="Quando não existe em estoque" />
                        <p:panelGrid columns="2">
                            <p:panelGrid columns="3">
                                <p:graphicImage library="imagem" name="positivar.png" width="20" height="20" alt="Ativar" />
                                <p:radioButton id="opt23" for="EstoqueAcabandoSOR" itemIndex="1"/>  
                                <p:panelGrid columns="1">
                                    <h:outputLabel for="opt23" value="Permitir compra para daqui a" />  
                                </p:panelGrid>
                            </p:panelGrid>
                            <p:panelGrid columns="2">
                                <p:inputText style="width: 60px" />
                                <h:outputText value="dias" />
                            </p:panelGrid>

                            <p:panelGrid columns="3">
                                <p:graphicImage library="imagem" name="Error_Icon.png" width="20" height="20" alt="Ativar" />
                                <p:radioButton id="opt13" for="EstoqueAcabandoSOR" itemIndex="0"/> 
                                <p:panelGrid columns="1">
                                    <h:outputText value="Negar compra" />  
                                </p:panelGrid>
                            </p:panelGrid>
                            <p:tooltip for="opt13" value="Se marcado no lugar do preco aparecerá um botão (me avise quando chegar) " showEffect="clip" hideEffect="explode" />  
                        </p:panelGrid>




                        <h:outputText value="Fabricante" />
                        <p:panelGrid columns="3">
                            <p:selectOneMenu>
                                <f:selectItem itemLabel="-- Escolha (opcional) --" />
                            </p:selectOneMenu>
                            <p:commandLink id="fabricCL">
                                <p:graphicImage library="imagem" name="file-add-icon.png" width="20" height="20"/>
                                <h:outputText value=" Criar" />
                            </p:commandLink>
                            <p:tooltip for="fabricCL" value="Criar um novo fabricante" showEffect="clip" hideEffect="explode" />  
                        </p:panelGrid>


                        <h:outputText value="Fornecedor" />
                        <p:panelGrid columns="3">
                            <p:selectOneMenu>
                                <f:selectItem itemLabel="-- Escolha (opcional) --" />
                            </p:selectOneMenu>
                            <p:commandLink id="fonrcCL">
                                <p:graphicImage library="imagem" name="file-add-icon.png" width="20" height="20"/>
                                <h:outputText value=" Criar" />
                            </p:commandLink>
                            <p:tooltip for="fonrcCL" value="Criar um novo fornecedor" showEffect="clip" hideEffect="explode" />  
                        </p:panelGrid>


                    </p:panelGrid>











                    <br />
                    <hr />
                    <br />

                    <!--QUARTA PARTE-->



                    <br />
                    <hr />
                    <br />
                    <!--QUINTA PARTE-->

                    <p:panelGrid columns="2">
                        <h:outputText value="Catégoria" />
                        <p:selectOneMenu value="#{adminCategoriaMB.idCategoriaPai}" onchange="">
                            <f:selectItem itemLabel="Categoria" itemValue="0"/>
                            <f:selectItems  value="#{adminCategoriaMB.categoriaPai}" var="item" itemLabel="#{item.descricao}" itemValue="#{item.id}" />
                            <f:ajax render="sub1pg" resetValues="true" />  
                        </p:selectOneMenu>


                        <h:outputText value="Sub-Catégoria" />
                        <h:panelGroup id="sub1pg" >

                            <p:selectOneMenu value="#{adminCategoriaMB.idCategoriaFilha1}">
                                <f:selectItem itemLabel="Categoria" itemValue=""/>
                                <f:selectItems  value="#{adminCategoriaMB.categoriaFilha1}" var="item" itemLabel="#{item.descricao}" itemValue="#{item.id}" />
                                <f:ajax render="sub2pg" resetValues="true" /> 
                            </p:selectOneMenu>
                        </h:panelGroup>

                        <h:outputText value="Sub-Catégoria" />
                        <h:panelGroup id="sub2pg">
                            <p:selectOneMenu value="#{adminCategoriaMB.idCategoriaFilha2}">
                                <f:selectItem itemLabel="Categoria" itemValue=""/>
                                <f:selectItems  value="#{adminCategoriaMB.categoriaFilha2}" var="item" itemLabel="#{item.descricao}" itemValue="#{item.id}" />

                            </p:selectOneMenu>
                        </h:panelGroup>



                    </p:panelGrid>

                    <br />
                    <hr />
                    <br />


                    <!--SEXTA PARTE-->
                    <p:panelGrid columns="2" styleClass="semBorda">

                        <h:outputText value="Descrição" />
                        <p:editor value="#{adminSessionMB.produto.descricao}"/>

                        <h:outputText value="DadosTecnicos" />
                        <p:editor value="#{adminSessionMB.produto.descricao}"/>

                        <h:outputText value="Foto" />
                        <p:fileUpload fileUploadListener="#{adminSessionMB.uploadFotos}" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" sizeLimit="65534" value="#{adminSessionMB.arquivo}" mode="advanced" label="inserir foto"/>


                        <h:outputText value="Tags" />
                        <p:inputText value="#{adminSessionMB.produto.descricao}"/>


                    </p:panelGrid>
                </h:panelGroup>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

